<?php namespace Asset;

use Illuminate\Console\Command;

use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;

class AssetCommand extends Command {
	
	/**
	 * The console command name.
	 *
	 * @var string
	 */
    protected $name = "asset";

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = "Lists asset commands.";

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
    	parent::__construct();
    }
    
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $this->line("<command>asset:combine</command> <info>combines multiple resource files.</info>");
        $this->line("<command>asset:minify</command> <info>minifies multiple resource files.</info>");
    }

    protected function getPath()
    {
        return public_path();
    }

    protected function getCollection($input, $filters = [])
    {
        $input      = explode(",", $input);
        $collection = new AssetCollection([], $filters);

        foreach ($input as $asset) {
            $collection->add(new FileAsset($this->getPath() . "/" . $asset));
        }

        return $collection;
    }

    protected function setOutput($path, $content)
    {
        return \File::put($this->getPath() . "/" . $path, $content);
    }
}